[E2013] [EWS] [PHP] [Windows] : Creating navigation shortcut pointing to a calendar, getting draft message instead.

Hi,

A couple days ago we asked about how to create a shared calendar without the need to accept a sharing request email. We got this answer: http://social.msdn.microsoft.com/Forums/exchange/en-US/eb49d42d-f961-42f6-8732-4bc3d0987b18/sharing-a-calendar-using-ews-and-phpews-without-sending-share-invitation

We read the documentation and started trying the implementation to make it work. So far this is the properties we set for our request to the method CreateItem

//PidTagMessageClass 
$sType = new EWSType_PathToExtendedFieldType();
$sType->PropertyTag = "0x001A";
$sType->PropertyType = EWSType_MapiPropertyTypeType::STRING;

$objExtendedPropertyType = new EWSType_ExtendedPropertyType();
$objExtendedPropertyType->ExtendedFieldURI = $sType;
$objExtendedPropertyType->Value = "IPM.Microsoft.WunderBar.Link";
$a_sExtendedProperties[] = $objExtendedPropertyType;

//PidTagNormalizedSubject  
$sType = new EWSType_PathToExtendedFieldType();
$sType->PropertyTag = "0x0E1D";
$sType->PropertyType = EWSType_MapiPropertyTypeType::STRING;

$objExtendedPropertyType = new EWSType_ExtendedPropertyType();
$objExtendedPropertyType->ExtendedFieldURI = $sType;
$objExtendedPropertyType->Value = "Meetings";
$a_sExtendedProperties[] = $objExtendedPropertyType;

//PidTagWlinkSaveStamp   
//$sType = new EWSType_PathToExtendedFieldType();
//$sType->PropertyTag = "0x0E1D";
//$sType->PropertyType = EWSType_MapiPropertyTypeType::STRING;
//
//$objExtendedPropertyType = new EWSType_ExtendedPropertyType();
//$objExtendedPropertyType->ExtendedFieldURI = $sType;
//$objExtendedPropertyType->Value = "Meetings";
//$a_sExtendedProperties[] = $objExtendedPropertyType;

//PidTagWlinkType
$sType = new EWSType_PathToExtendedFieldType();
$sType->PropertyTag = "0x6849";
$sType->PropertyType = EWSType_MapiPropertyTypeType::INTEGER;

$objExtendedPropertyType = new EWSType_ExtendedPropertyType();
$objExtendedPropertyType->ExtendedFieldURI = $sType;
$objExtendedPropertyType->Value = 2;
$a_sExtendedProperties[] = $objExtendedPropertyType;

//PidTagWlinkFlags
$sType = new EWSType_PathToExtendedFieldType();
$sType->PropertyTag = "0x684A";
$sType->PropertyType = EWSType_MapiPropertyTypeType::INTEGER;

$objExtendedPropertyType = new EWSType_ExtendedPropertyType();
$objExtendedPropertyType->ExtendedFieldURI = $sType;
$objExtendedPropertyType->Value = 1024;
$a_sExtendedProperties[] = $objExtendedPropertyType;

//PidTagWlinkOrdinal 
//$sType = new EWSType_PathToExtendedFieldType();
//$sType->PropertyTag = "0x684B";
//$sType->PropertyType = EWSType_MapiPropertyTypeType::BINARY;
//
//$objExtendedPropertyType = new EWSType_ExtendedPropertyType();
//$objExtendedPropertyType->ExtendedFieldURI = $sType;
//$objExtendedPropertyType->Value = 1024;
//$a_sExtendedProperties[] = $objExtendedPropertyType;

//PidTagWlinkEntryId 
$sType = new EWSType_PathToExtendedFieldType();
//$sType->PropertyTag = "0x0FFF";
$sType->PropertyTag = "0x684C";
$sType->PropertyType = EWSType_MapiPropertyTypeType::BINARY;

$objExtendedPropertyType = new EWSType_ExtendedPropertyType();
$objExtendedPropertyType->ExtendedFieldURI = $sType;
$objExtendedPropertyType->Value = $sEntryID;
$a_sExtendedProperties[] = $objExtendedPropertyType;

//PidTagWlinkRecordKey  
$sType = new EWSType_PathToExtendedFieldType();
//$sType->PropertyTag = "0x0FF9";
$sType->PropertyTag = "0x684D";
$sType->PropertyType = EWSType_MapiPropertyTypeType::BINARY;

$objExtendedPropertyType = new EWSType_ExtendedPropertyType();
$objExtendedPropertyType->ExtendedFieldURI = $sType;
$objExtendedPropertyType->Value = $sRecordID;
$a_sExtendedProperties[] = $objExtendedPropertyType;

//PidTagWlinkStoreEntryId  
$sType = new EWSType_PathToExtendedFieldType();
//$sType->PropertyTag = "0x0FFB";
$sType->PropertyTag = "0x684E";
$sType->PropertyType = EWSType_MapiPropertyTypeType::BINARY;

$objExtendedPropertyType = new EWSType_ExtendedPropertyType();
$objExtendedPropertyType->ExtendedFieldURI = $sType;
$objExtendedPropertyType->Value = $sStoreID;
$a_sExtendedProperties[] = $objExtendedPropertyType;

//PidTagWlinkFolderType
$sType = new EWSType_PathToExtendedFieldType();
$sType->PropertyTag = "0x684F";
$sType->PropertyType = EWSType_MapiPropertyTypeType::CLSID;

$objExtendedPropertyType = new EWSType_ExtendedPropertyType();
$objExtendedPropertyType->ExtendedFieldURI = $sType;
//$objExtendedPropertyType->Value = '{0x02780600, 0x0000, 0x0000, {0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46}}';
$objExtendedPropertyType->Value = '0006F063-0000-0000-C000-000000000046';
$a_sExtendedProperties[] = $objExtendedPropertyType;

//PidTagWlinkSection
$sType = new EWSType_PathToExtendedFieldType();
$sType->PropertyTag = "0x6852";
$sType->PropertyType = EWSType_MapiPropertyTypeType::INTEGER;

$objExtendedPropertyType = new EWSType_ExtendedPropertyType();
$objExtendedPropertyType->ExtendedFieldURI = $sType;
$objExtendedPropertyType->Value = '3';
$a_sExtendedProperties[] = $objExtendedPropertyType;

$request = new EWSType_CreateItemType();
$request->Items = new EWSType_CreateItemType();
$request->Items->Item = new EWSType_ItemType();
//$request->Items->Item->ItemClass = "IPM.Microsoft.WunderBar.Link";
//$request->Items->Item->Subject = "SharedCalendar";
$request->Items->Item->ExtendedProperty = $a_sExtendedProperties;

$request->ParentFolderId = new EWSType_NonEmptyArrayOfBaseFolderIdsType();
$request->ParentFolderId->DistinguishedFolderId = new EWSType_DistinguishedFolderIdType();
$request->ParentFolderId->DistinguishedFolderId->Id = EWSType_DistinguishedFolderIdNameType::CALENDAR;
$request->ParentFolderId->DistinguishedFolderId->Mailbox = new EWSType_MailboxData();
$request->ParentFolderId->DistinguishedFolderId->Mailbox->EmailAddress = 'user@domain.ca';
$request->ParentFolderId->DistinguishedFolderId->Mailbox->RoutingType  = 'SMTP';


$response = $ews->CreateItem($request);

We use FindItem with extended properties to fill the value
$sEntryID = 0x0FFF
$sStoreID = 0x0FFB
$sRecordID = 0x0FF9

When we run this script, we are getting a draft message instead of a navigation shortcut.

We tried writing the $sEntryID, $sStoreID, $sRecordID at the same property tag as the one we got them from but we get an error 503 from the server.

We think we are near the final answer but there is a gap we can't make it work. If anyone has an answer to fill that gap we will greatly appreciate it.

Thanks and have a nice day.

June 19th, 2013 5:45pm

The Navigational Shortcuts are FAI (Folder Assoicated Items) and they need to be saved to the CommonViews Folder http://msdn.microsoft.com/en-us/library/office/cc815648.aspx of the Mailbox in question. (You should really use a MAPI Editor to look at a Mailbox yourself or you just wont understand this http://technet.microsoft.com/en-us/library/bb508857(v=exchg.65).aspx).

You also need to use the MessageType else you wont be able to modify the ItemClass and you need to set the IsAssocated Properties so the Item is saved as an FAI Item (which you will only able to view with a Mapi editor).

            MessageType msType = new MessageType();
            msType.IsAssociated = true;
            msType.IsAssociatedSpecified = true;
Cheers
Glen

Free Windows Admin Tool Kit Click here and download it now
June 20th, 2013 1:18pm

Hi,

Thanks again Glen for your help, I downloaded MFCMAPI, OutlookSpy and EWSEditor.

With OutlookSpy, I can't get the properties of the elements of my shared calendar. So I went with MFCMAPI instead and finally got to see the properties of the objects in my mailbox.

There is only a small problem, maybe I lack knowledge about how Exchange keeps the data, but there is nothing in my folder Common Views, the shared calendar I have in my mailbox are in Shared Data.

When I open my shared calendar in MFCMAPI, I don't have the properties (IsAssociated, IsAssociatedSpecified) in the object.

I also tried to make a MessageType instead of ItemType, but I still get a draft message. When I check the values they seems correct but there are some attributes missing I presume it's for the same reason we get a draft message instead.

June 20th, 2013 10:31pm

> but there is nothing in my folder Common Views, the shared calendar I have in my mailbox are in Shared Data.

You need to use the Open Associated Content to see the FAI items in the folder, MFCMapi let you look at the MAPI properties of a object, the Strongly type properties of the Web Service Object are different (generally their is an underlying MAPI property to match it).

>I also tried to make a MessageType instead of ItemType, but I still get a draft message. >When I check the values they seems correct but there are some attributes missing I >presume it's for the same reason we get a draft message instead.

You need to use the IsAssoicated properties to make sure the message is saved to FAI collection (or the commonview folder which you will need to find the Id of using FindFolder operations) once it is you won't be able to see the Items in the folder without a Mapi editor. Being a draft is just a misnomer is not important one way of the other. But you need to look at an existing ShortCut Item to help make what your trying to do work.

Cheers
Glen

Free Windows Admin Tool Kit Click here and download it now
June 21st, 2013 3:02pm

Hi Mr Scales

We finally found the FAI with your help. Thank you very much.

While comparing the values, we noticed the property PR_MESSAGE_FLAGS has a value of 73 while the ones we are creating have a value of 9. So we assume the IsAssociated property we set is saved in that property. The problem we have now is when we try to edit the value using MFCMAPI, we get an error:

Problem array:
Index: 0x00000000, ulPropTag: Tag: 0x0E070003
Type: PT_LONG
Property Name(s): PR_MESSAGE_FLAGS, PidTagMessageFlags, ptagMessageFlags
DASL: http://schemas.microsoft.com/mapi/proptag/0x0E070003, scode: 0x8004011A = MAPI_E_COMPUTED

In file PropertyEditor.cpp
On line 720

Another problem we encounter is when we set the IsAssociated on a message type, we get this error:

The request failed schema validation: The element 'Message' in namespace 'http://schemas.microsoft.com/exchange/services/2006/types' has invalid child element 'IsAssociated' in namespace 'http://schemas.microsoft.com/exchange/services/2006/types'. List of possible elements expected: 'WebClientReadFormQueryString, WebClientEditFormQueryString, ConversationId, UniqueBody, Sender, ToRecipients, CcRecipients, BccRecipients, IsReadReceiptRequested, IsDeliveryReceiptRequested, ConversationIndex, ConversationTopic, From, InternetMessageId, IsRead, IsResponseRequested, References, ReplyTo, ReceivedBy, ReceivedRepresenting' in namespace 'http://schemas.microsoft.com/exchange/services/2006/types'.

Here is the request we send to the server

<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="http://schemas.microsoft.com/exchange/services/2006/types" xmlns:ns2="http://schemas.microsoft.com/exchange/services/2006/messages">
	<SOAP-ENV:Header>
		<ns1:RequestServerVersion Version="Exchange2010"/>
		<ns1:ExchangeImpersonation>
			<ns1:ConnectingSID>
				<ns1:PrimarySmtpAddress>name@domain.com</ns1:PrimarySmtpAddress>
			</ns1:ConnectingSID>
		</ns1:ExchangeImpersonation>
	</SOAP-ENV:Header>
	<SOAP-ENV:Body>
		<ns2:CreateItem MessageDisposition="SaveOnly">
			<ns2:SavedItemFolderId>
				<ns1:FolderId Id="AQMkADhkMjIAOGJlMi1hZTU4LTQwNzcALTliNTEtMjFjMjVmYTI5YzZmAC4AAAMUYhf/m7/tS4JqTUCpQ3mcAQDgBdgbPZMxQ5EP5jMlLTMUAAADBwAAAA==" ChangeKey="AQAAABYAAADgBdgbPZMxQ5EP5jMlLTMUAAAAAAAv"/>
			</ns2:SavedItemFolderId>
			<ns2:Items>
				<ns1:Message>
					<ns1:ItemClass>IPM.Microsoft.WunderBar.Link</ns1:ItemClass>
					<ns1:ExtendedProperty>
						<ns1:ExtendedFieldURI PropertyTag="0x0E1D" PropertyType="String"/>
						<ns1:Value>Meetings</ns1:Value>
					</ns1:ExtendedProperty>
					<ns1:ExtendedProperty>
						<ns1:ExtendedFieldURI PropertyTag="0x6849" PropertyType="Integer"/>
						<ns1:Value>2</ns1:Value>
					</ns1:ExtendedProperty>
					<ns1:ExtendedProperty>
						<ns1:ExtendedFieldURI PropertyTag="0x684A" PropertyType="Integer"/>
						<ns1:Value>0</ns1:Value>
					</ns1:ExtendedProperty>
					<ns1:ExtendedProperty>
						<ns1:ExtendedFieldURI PropertyTag="0x684C" PropertyType="Binary"/>
						<ns1:Value>AAAAABuFufJwK7JLrrjtyLW4G74BAJILSV5u+zNNgnSrc3p/IHUAAAsLERYAAA==</ns1:Value>
					</ns1:ExtendedProperty>
					<ns1:ExtendedProperty>
						<ns1:ExtendedFieldURI PropertyTag="0x684D" PropertyType="Binary"/>
						<ns1:Value>G4W58nArskuuuO3Itbgbvg==</ns1:Value>
					</ns1:ExtendedProperty>
					<ns1:ExtendedProperty>
						<ns1:ExtendedFieldURI PropertyTag="0x684E" PropertyType="Binary"/>
						<ns1:Value>AAAAADihuxAF5RAaobsIACsqVsIAAEVNU01EQi5ETEwAAAAAAAAAABtV+iCqZhHNm8gAqgAvxFoMAAAAU2VydmVyMDIuYWQuZXptYXguY2EA+IiE9XzbjEiqZSWmrHNVveTfb5k2QxhGt33Pu/mxDMM=</ns1:Value>
					</ns1:ExtendedProperty>
					<ns1:ExtendedProperty>
						<ns1:ExtendedFieldURI PropertyTag="0x6852" PropertyType="Integer"/>
						<ns1:Value>3</ns1:Value>
					</ns1:ExtendedProperty>
					<ns1:ExtendedProperty>
						<ns1:ExtendedFieldURI PropertyTag="0x0E07" PropertyType="Integer"/>
						<ns1:Value>73</ns1:Value>
					</ns1:ExtendedProperty>
					<ns1:IsAssociated>true</ns1:IsAssociated>
				</ns1:Message>
			</ns2:Items>
		</ns2:CreateItem>
	</SOAP-ENV:Body>
</SOAP-ENV:Envelope>

We think we are getting closer each day to the solution and we appreciate your help.

Thank you very much and have a nice day.

July 4th, 2013 2:11pm

The ability to create FAI (Folder Assoicated Items) was added in Exchange 2010 (see http://msdn.microsoft.com/en-us/library/exchange/aa494306%28v=exchg.140%29.aspx) it sounds like the proxies your using where generated against an Exchange 2007 server or maybe your server hasn't been patched (check the definition). I would try to regenerate the proxy. The only way to create an FAI Item using EWS it to use this property.

The MessageFlags property is Computed from other property values so you can't modify it once its been created.

Cheers
Glen

Free Windows Admin Tool Kit Click here and download it now
July 5th, 2013 7:31pm

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics